import config
from time import strftime
from utils import *


def register():
	return PrintTime()


class PrintTime:
	def __init__(self):
		self.type = 'passive'
		self.help = \
'''显示时间：
	用法：*时间
	显示当前时间。'''

	def run(self, gum, msg):
		if not msg['type'] in ['FriendMessage', 'GroupMessage'] \
				or len(msg['messageChain']) <= 1 \
				or msg['messageChain'][1]['type'] != 'Plain' \
				or msg['messageChain'][1]['text'] != '*时间':
			return

		chain = MsgChain()
		chain.addPlain('糖糖提醒您，现在的时间是：\n')

		s = strftime('%Y{0}%m{1}%d{2} %p %H:%M:%S %a').format('年', '月', '日')
		s = s.replace('AM', '上午')
		s = s.replace('PM', '下午')
		s = s.replace('Sun', '周日')
		s = s.replace('Mon', '周一')
		s = s.replace('Tue', '周二')
		s = s.replace('Wed', '周三')
		s = s.replace('Thu', '周四')
		s = s.replace('Fri', '周五')
		s = s.replace('Sat', '周六')
		chain.addPlain(s)

		autoReply(chain, gum)